<template>
  <div>
    <el-container>
      <el-header>
        <el-menu
        :default-active="activePath"
        mode="horizontal" 
        router
      >
        <el-menu-item :index="item.path" v-for="(item,index) in routerList" :key="index" @click="saveNavPath(item.path)">
            <span slot="title">{{item.name}}</span>
        </el-menu-item>
        </el-menu>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      routerList: [
        { path: "/discover/personalrecom", name: "个性推荐" },
        { path: "/discover/playlist", name: "歌单" },
        { path: "/discover/toplist", name: "排行榜" },
        { path: "/discover/artistlist", name: "歌手" },
        { path: "/discover/zuixin", name: "最新音乐" },
      ],
      activePath:'',
    };
  },
  created(){
      this.activePath = window.sessionStorage.getItem('activePath');
  },
  methods:{
    saveNavPath(activePath){
      window.sessionStorage.setItem('activePath',activePath);
      this.activePath = activePath;
    }
  }
};
</script>

<style lang="less" scoped>
.el-menu-item{
  height: 30px;
  line-height: 30px;
}
.el-menu-item:hover{
  font-size: 20px;
  color: #ff2727 !important;
  border-bottom: 2px solid;
}
.el-menu-item.is-active {
  font-size: 20px;
  color: #ff2727 !important;
  border-bottom: 3px solid !important;
}
</style>